'''
Created on Jun 1, 2011

@author: Steve
'''
import os, sys

import pygame #@UnresolvedImport
from pygame.sprite import Sprite #@UnresolvedImport

SCREEN_WIDTH, SCREEN_HEIGHT = 400, 400
BG_COLOR = 150, 150, 80

clock = pygame.time.Clock()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), 0, 32)

class Game():
    
    image = pygame.image.load("creep.png")
    
    def __init__(self):
        
        pygame.init()
        pygame.display.set_caption("test")
        self.x = 380
        self.y = 380

    def update(self):
        
        keys = pygame.key.get_pressed()
        
        if keys[pygame.K_LEFT]:
            self.x = self.x - 1
        if keys[pygame.K_RIGHT]:
            self.x = self.x + 1
            
#        return

    def draw(self):
        
        screen.fill(BG_COLOR)
        screen.blit(self.image, (self.x, self.y))
        
        self.drawRect()
        self.drawPoly()
        self.drawCircle()
        
        pygame.display.flip()
    
    def drawRect(self):
        screen.lock()
        pygame.draw.rect(screen, (140, 140, 140), pygame.Rect((0, 0), (32, 32)))
        screen.unlock()
        
    def drawPoly(self):
        points=[(20,120),(140,140),(110,30)]
        color=(255,255,0)
        
        screen.lock
        pygame.draw.polygon(screen, color, points)
        screen.unlock
        
    def drawCircle(self):
        color=(230,170,0)
        position=(300,176)
        radius=(60)
        
        screen.lock
        pygame.draw.circle(screen, color, position, radius)
        screen.unlock
    
    def mainLoop(self):
        while True:
    
            clock.tick(50)
            
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()
    
            self.update()
            self.draw()
        
if __name__ == '__main__' :
    game = Game()
    game.mainLoop()

